package Text6;

import java.util.*;

public class Main {
    static int N = 1010, mod = (int) 1e9 + 7;
    static int[] f = new int[N];
    static int[] g = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Arrays.fill(f, -0x3f3f3f3f);
        f[0] = 0;
        g[0] = 1;
        for (int i = 0; i < n; i++) {
            int v = in.nextInt();
            int w = in.nextInt();
            for (int j = m; j >= v; j--) {
                int maxv = Math.max(f[j], f[j - v] + w);
                int cnt = 0;
                if (f[j] == maxv) {
                    cnt = (cnt + g[j]) % mod;
                }
                if (f[j - v] + w == maxv) {
                    cnt = (cnt + g[j - v]) % mod;
                }
                g[j] = cnt;
                f[j] = maxv;
            }
        }
        int res = 0, ans = 0;
        for (int i = 1; i <= m; i++) {
            if (f[res] < f[i]) {
                res = i;
            }
        }
        for (int i = 0; i <= m; i++) {
            if (f[res] == f[i]) {
                ans = (ans + g[i]) % mod;
            }
        }
        System.out.println(ans);
    }
}
